/**
 * Staff 职位
 */
const { DataTypes, Deferrable } = require('sequelize')
const sequelize = require('./db')
const Post = require('./Post')
const Contempt = require('./Contempt')

const Staff = sequelize.define('Staff', {
    id: { type: DataTypes.INTEGER, autoIncrement: true, primaryKey: true },
    name: { type: DataTypes.STRING, allowNull: false },
    // post_id: {
    //     type: DataTypes.INTEGER,
    //     references: {
    //         model: Post,
    //         key: 'id'
    //     },
    //     deferrable: Deferrable.INITIALLY_IMMEDIATE
    // },
    // contempt_id: {
    //     type: DataTypes.INTEGER,
    //     references: {
    //         model: Contempt,
    //         key: 'id'
    //     }
    // }
})
// 不知道为什么我自定义的外键名称以后出现了两个外键
Post.hasMany(Staff)
Staff.belongsTo(Post)

Contempt.hasMany(Staff)
Staff.belongsTo(Contempt)

module.exports = Staff